﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TDSReport.aspx.cs" Inherits="Main_Reports_ServiceInvoice_TDSReport" %>

<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>TDS Report</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <link href="../../../Styles/Tab/StyleSheet.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .ajax__tab_technorati-theme .ajax__tab_hover .ajax__tab_outer
        {
            cursor: pointer;
        }
        .ajax__tab_technorati-theme .ajax__tab_hover .ajax__tab_inner
        {
            cursor: pointer;
        }
        .ajax__tab_technorati-theme .ajax__tab_hover .ajax__tab_tab
        {
            cursor: pointer;
        }
    </style>

    <script type="text/javascript" language="javascript">    
        function openSetting() {          
            window.open('../../ServiceInvoice/TdsReportSetting.aspx','', 'left=250,top=150,width=370,height=370');
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scriptmanager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <acc:heading ID="pagehead" runat="server" HeadingText="TDS Report" />
    <asp:HiddenField ID="hidActiveIndex" runat="server" Value="0" />
    <asp:HiddenField ID="hidReportOpt" runat="server" />
    <asp:HiddenField ID="hidViewOpt" runat="server" />
    <asp:HiddenField ID="hidLid" runat="server" />
    <center>
        <asp:Label ID="lblMsg" runat="server" ForeColor="#f29e08" Font-Bold="true"></asp:Label><br />
        <br />
    </center>
    <div style="width: 70%; margin-left: 20%; margin-right: 10%;">
        <ajaxToolkit:TabContainer Width="80%" ID="Tabs" runat="server" CssClass="ajax__tab_technorati-theme">
            <ajaxToolkit:TabPanel ID="tabpanel1" runat="server" HeaderText="TDS Report">
                <ContentTemplate>
                    <table style="width: 100%;" class="tablecontent">
                        <tr>
                            <td>
                                <span style="background-color: #f0f0f0; font-weight: bold;">TDS Report</span>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-left: 10%;">
                                <asp:RadioButtonList ID="rdbtnlst1" runat="server" RepeatDirection="Horizontal">
                                    <asp:ListItem Value="0">Received&nbsp;&nbsp;&nbsp;</asp:ListItem>
                                    <asp:ListItem Value="1">Pending&nbsp;&nbsp;&nbsp;</asp:ListItem>
                                    <asp:ListItem Text="Both" Value="2" Selected="True"></asp:ListItem>
                                </asp:RadioButtonList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="background-color: #f0f0f0; font-weight: bold;">View</span>
                            </td>
                        </tr>
                        <tr>
                            <td style="padding-left: 10%;">
                                <asp:RadioButtonList ID="rdbtnlst2" runat="server" RepeatDirection="Horizontal">
                                    <asp:ListItem Text="TDS Report" Value="0" Selected="True"></asp:ListItem>
                                    <asp:ListItem Text="TDS/ST Report" Value="1"></asp:ListItem>
                                </asp:RadioButtonList>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:GridView ID="grdTDSReport" runat="server" CssClass="gridview" 
                                    DataKeyNames="LID" Width="100%" AllowPaging="True" AutoGenerateColumns="False" 
                                    OnPageIndexChanging="grdTDSReport_OnPageIndexChanging">
                                    <Columns>
                                        <asp:TemplateField HeaderText="Select">
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkOpt" runat="server" onclick="CheckSelectAll();" />
                                            </ItemTemplate>
                                            <ItemStyle Width="20px" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Customer Name">
                                            <ItemTemplate>
                                                <asp:Label ID="lblLedger" runat="server" Text='<%#Eval("LNAME") %>'></asp:Label>
                                                <asp:HiddenField ID="hidLID" runat="server" Value='<%#Eval("LID") %>' />
                                            </ItemTemplate>
                                            <ItemStyle Width="400px" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <AlternatingRowStyle CssClass="gridview_alternate" />
                                    <EmptyDataTemplate>
                                        <center>
                                            <span style="font-weight: bold; color: Red;">No Record Found !</span>
                                        </center>
                                    </EmptyDataTemplate>
                                </asp:GridView>
                            </td>
                        </tr>
                    </table>
                    <div>
                        <table width="100%" style="padding-top: 10px;">
                            <tr>
                                <td align="left" style="padding-top: 10px;">
                                    <asp:CheckBox ID="ChkSelectAll" runat="server" Text="Select All" 
                                        onclick="SelectAll(this.id);"  />
                                </td>
                                <td align="right" style="padding-top: 10px;">
                                    <asp:Button ID="btnDisplay" runat="server" Text="Display" CssClass="button" OnClientClick="return checkselected();"
                                        OnClick="btnDisplay_Click" />
                                </td>
                                <td align="left" style="padding-top: 10px;">
                                    &nbsp;&nbsp;<asp:Button ID="btnCancel" runat="server" CssClass="button" Text="Cancel"
                                        OnClick="btnCancel_Click" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </ContentTemplate>
            </ajaxToolkit:TabPanel>
            <ajaxToolkit:TabPanel ID="tabpanel2" runat="server" HeaderText="TDS Reminder">
                <ContentTemplate>
                    <asp:GridView ID="grdTDSReminder" runat="server" CssClass="gridview" AlternatingRowStyle-CssClass="gridview_alternate"
                        AllowPaging="true" PageSize="13" AutoGenerateColumns="false" Width="100%" OnPageIndexChanging="grdTDSReminder_OnPageIndexChanging">
                        <Columns>
                            <asp:TemplateField ItemStyle-Width="20px" HeaderText="Select">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkOpt2" runat="server" onclick="CheckSelectAll2();" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField ItemStyle-Width="400px" HeaderText="Customer Name">
                                <ItemTemplate>
                                    <asp:Label ID="lblLedger2" runat="server" Text='<%#Eval("LNAME") %>'></asp:Label>
                                    <asp:HiddenField ID="hidLID2" runat="server" Value='<%#Eval("LID") %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            <center>
                                <span style="font-weight: bold; color: Red;">No Record Found !</span>
                            </center>
                        </EmptyDataTemplate>
                    </asp:GridView>
                    <div>
                        <table width="100%" style="padding-top: 10px;">
                            <tr>
                                <td align="left" style="padding-top: 10px;">
                                    <asp:CheckBox ID="ChkSelectAll2" runat="server" Text="Select All" onclick="SelectAll2(this.id);" />
                                </td>
                                <td align="right" style="padding-top: 10px;">
                                    <asp:Button ID="btnSetting" runat="server" Text="Setting" CssClass="button" OnClientClick="openSetting();"
                                        OnClick="btnSetting_Click" />&nbsp;&nbsp;
                                    <asp:Button ID="btnDisplay2" runat="server" Text="Display" CssClass="button" OnClientClick="return checkselected2();"
                                        OnClick="btnDisplay2_Click" />
                                </td>
                                <td align="left" style="padding-top: 10px;">
                                    &nbsp;&nbsp;<asp:Button ID="btnCancel2" runat="server" CssClass="button" Text="Cancel"
                                        OnClick="btnCancel2_Click" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </ContentTemplate>
            </ajaxToolkit:TabPanel>
        </ajaxToolkit:TabContainer>
    </div>
    </form>
</body>

<script type="text/javascript" language="javascript">

    function SelectAll2(id) {

        //get reference of GridView control
        var grid = document.getElementById("<%= grdTDSReminder.ClientID %>");

        //variable to contain the cell of the grid
        var cell;
        if (grid.rows.length > 0) {
            //loop starts from 1. rows[0] points to the header.
            for (i = 1; i < grid.rows.length; i++) {
                //get the reference of first column
                cell = grid.rows[i].cells[0];

                //loop according to the number of childNodes in the cell
                for (j = 0; j < cell.childNodes.length; j++) {
                    //if childNode type is CheckBox
                    if (cell.childNodes[j].type == "checkbox") {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                        cell.childNodes[j].checked = document.getElementById(id).checked;
                    }
                }
            }
        }
    }

    function SelectAll(id) {

        //get reference of GridView control
        var grid = document.getElementById("<%= grdTDSReport.ClientID %>");

        //variable to contain the cell of the grid
        var cell;
        if (grid.rows.length > 0) {
            //loop starts from 1. rows[0] points to the header.
            for (i = 1; i < grid.rows.length; i++) {
                //get the reference of first column
                cell = grid.rows[i].cells[0];

                //loop according to the number of childNodes in the cell
                for (j = 0; j < cell.childNodes.length; j++) {
                    //if childNode type is CheckBox
                    if (cell.childNodes[j].type == "checkbox") {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                        cell.childNodes[j].checked = document.getElementById(id).checked;
                    }
                }
            }
        }
    }

    function CheckSelectAll2() {
        var countchecked = 0;
        //get reference of GridView control
        var grid = document.getElementById("<%= grdTDSReminder.ClientID %>");
        //variable to contain the cell of the grid
        var cell;
        if (grid.rows.length > 0) {
            //loop starts from 1. rows[0] points to the header.
            for (i = 1; i < grid.rows.length; i++) {
                //get the reference of first column
                cell = grid.rows[i].cells[0];
                //loop according to the number of childNodes in the cell
                for (j = 0; j < cell.childNodes.length; j++) {
                    //if childNode type is CheckBox
                    if (cell.childNodes[j].type == "checkbox") {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                        if (cell.childNodes[j].checked == true) {
                            countchecked = countchecked + 1;
                        }
                    }
                }

                if (countchecked + 2 == grid.rows.length) {
                    document.getElementById("Tabs_tabpanel2_ChkSelectAll2").checked = true;
                }
                else {
                    document.getElementById("Tabs_tabpanel2_ChkSelectAll2").checked = false;
                }
            }
        }
    }
    function CheckSelectAll() {
        var countchecked = 0;
        //var cdi =document.getElementById('<%=this.Tabs.ClientID%>');

        //get reference of GridView control
        var grid = document.getElementById("<%= grdTDSReport.ClientID %>");

        //variable to contain the cell of the grid
        var cell;
        if (grid.rows.length > 0) {
            //loop starts from 1. rows[0] points to the header.
            for (i = 1; i < grid.rows.length; i++) {
                //get the reference of first column
                cell = grid.rows[i].cells[0];

                //loop according to the number of childNodes in the cell
                for (j = 0; j < cell.childNodes.length; j++) {
                    //if childNode type is CheckBox
                    if (cell.childNodes[j].type == "checkbox") {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                        if (cell.childNodes[j].checked == true) {
                            countchecked = countchecked + 1;
                        }
                    }
                }
            }

            if (countchecked + 2 == grid.rows.length) {
                document.getElementById("Tabs_tabpanel1_ChkSelectAll").checked = true;
            }
            else {
                document.getElementById("Tabs_tabpanel1_ChkSelectAll").checked = false;
            }
        }
    }
    function checkselected2() {
        var flag = true;
        var checkedcount = 0;
        var grid = document.getElementById("<%= grdTDSReminder.ClientID %>");
        var cell;
        if (grid.rows.length > 0) {
            for (i = 1; i < grid.rows.length; i++) {
                cell = grid.rows[i].cells[0];
                for (j = 0; j < cell.childNodes.length; j++) {
                    if (cell.childNodes[j].type == "checkbox") {
                        if (cell.childNodes[j].checked == true) {
                            checkedcount = checkedcount + 1;
                        }
                    }
                }
            }
        }
        if (checkedcount <= 0) {
            alert("Please select a customer from list to display details !!");
            flag = false;
        }
        return flag;
    }
    function checkselected() {
        var flag = true;
        var checkedcount = 0;
        var grid = document.getElementById("<%= grdTDSReport.ClientID %>");
        var cell;
        if (grid.rows.length > 0) {
            for (i = 1; i < grid.rows.length; i++) {
                cell = grid.rows[i].cells[0];
                for (j = 0; j < cell.childNodes.length; j++) {
                    if (cell.childNodes[j].type == "checkbox") {
                        if (cell.childNodes[j].checked == true) {
                            checkedcount = checkedcount + 1;
                        }
                    }
                }
            }
        }
        if (checkedcount <= 0) {
            alert("Please select a customer from list to display details !!");
            flag = false;
        }
        return flag;
    }
</script>

</html>
